package jwu2.gui;

import java.util.HashSet;
import java.util.Set;
import jwu2.core.Addon;

/**
 * This class dispatches events to listeners whenever a particular event happens
 * @author jbk
 */
public class GUIEventDispatcher {
    private static Set<GUIEventListener> listeners = new HashSet<GUIEventListener>();
    
    public static void addListener(GUIEventListener listener){
        listeners.add(listener);
    }

    public static void fireBundleAddAddonEvent(Addon addon) {
        for (GUIEventListener listener : listeners){
            listener.onBundleAddAddonEvent(addon);
        }
    }

    public static void fireBundleRemoveAddonEvent(Addon addon) {
        for (GUIEventListener listener : listeners){
            listener.onBundleRemoveAddonEvent(addon);
        }
    }
    
    public static void fireInstallAddonEvent(Addon addon){
        for (GUIEventListener listener : listeners){
            listener.onInstallAddonEvent(addon);
        }
    }

    public static void fireRemoveAddonEvent(Addon addon) {
        for (GUIEventListener listener : listeners){
            listener.onRemoveAddonEvent(addon);
        }
    }
}
